<template>
	<div>

	<div class="main">
		<!-- <h1 style="margin-top:0.5%;">&nbsp;</h1> -->
		<div
			style="font-size: 25px;border: 1px solid red;height:70px;display: flex;justify-content:space-around;align-items: center;">


			<div>
				北京时间:
			</div>
			<div>
				欢迎: <span style="color: blue;">{{this.psUser.username}}</span>
			</div>
			<div>
				角色: <span style="color: red;">{{this.role[0]}}</span>

			</div>
			<div>
				<el-button type="danger" @click="exit()" plain>退出登录</el-button>
			</div>
		</div>
		<el-container style="height: 100vh; border: 1px solid #eee">
			<el-aside width="200px" style="background-color: rgb(238, 241, 246)">
				<el-menu :default-openeds="['1','2']">

					<el-submenu index="1">
						<template slot="title"><i class="el-icon-setting"></i>电力巡检系统</template>
						<el-menu-item-group>
							<template slot="title"></template>
							<el-submenu index="1-1">
								<template slot="title">我的工作台</template>
								<el-menu-item index="1-1-1" @click="$router.push('/BacklogList')">代办列表</el-menu-item>
								<el-menu-item index="1-1-2"
									@click="$router.push('/PersonalDataUpd')">个人资料修改</el-menu-item>
							</el-submenu>

						</el-menu-item-group>
						<el-menu-item-group>
							<template slot="title"></template>
							<el-submenu index="1-2">
								<template slot="title">系统管理</template>
								<el-menu-item index="1-2-1" @click="$router.push('/RoleManager')">角色管理</el-menu-item>
								<el-menu-item index="1-2-2" @click="$router.push('/UserManager')">用户管理</el-menu-item>
								<el-menu-item index="1-2-3" @click="$router.push('/RolePowerManager')">角色权限配置</el-menu-item>
								<el-menu-item index="1-2-4" @click="$router.push('/SystemConfig')">系统配置</el-menu-item>
							</el-submenu>

						</el-menu-item-group>


			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-3">
			     <template slot="title">杆塔管理</template>
			    <el-menu-item index="1-3-1" @click="$router.push('/Pspoleinfo')">杆塔管理</el-menu-item>
			   </el-submenu>
			   
			 </el-menu-item-group>
			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-4">
			     <template slot="title">线路管理</template>
			    <el-menu-item index="1-4-1" @click="$router.push('/psLineInfo')">线路管理</el-menu-item>
			   </el-submenu>
			   
			 </el-menu-item-group>
			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-5">
			     <template slot="title">缺陷管理</template>
			    <el-menu-item index="1-5-1" @click="$router.push('/defetType')">缺陷类型设置</el-menu-item>
			    <el-menu-item index="1-5-2" @click="$router.push('/defetLevelAfrim')">缺陷等级确认</el-menu-item>
			    <el-menu-item index="1-5-2" @click="$router.push('/defetLevelAffirm')">缺陷等级确认</el-menu-item>
			   </el-submenu>
			   
			 </el-menu-item-group>
			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-6">
			     <template slot="title">巡检任务管理</template>
			    <el-menu-item index="1-6-1" @click="$router.push('/InspectionTask')">巡检任务制定与分配</el-menu-item>
			    <el-menu-item index="1-6-2" @click="$router.push('/ExecuteInspectionTask')">巡检任务执行与回执</el-menu-item>
				<el-menu-item index="1-6-3" @click="$router.push('/FlawInfo')">缺陷查询</el-menu-item>
			   </el-submenu>
			   
			 </el-menu-item-group>
			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-7">
			     <template slot="title">消缺任务管理</template>
			    <el-menu-item index="1-7-1" @click="$router.push('/Solvetask')">消缺任务制定与分配</el-menu-item>
			    <el-menu-item index="1-7-2" @click="$router.push('/ExecuteSolvetask')">消缺任务执行与回执</el-menu-item>
				<el-menu-item index="1-7-3" @click="$router.push('/BlankingInfo')">消缺查询</el-menu-item>
			   </el-submenu>
			   
			 </el-menu-item-group>
			 <el-menu-item-group>
			   <template slot="title"></template>
			   <el-submenu index="1-8">
			     <template slot="title">信息统计</template>
			    <el-menu-item index="1-8-1" @click="$router.push('/Transfer')">巡检记录统计</el-menu-item>
			    <el-menu-item index="1-8-2" @click="$router.push('/QueryBank')">消缺记录统计</el-menu-item>
			   </el-submenu>

				</el-menu-item-group>


					
					</el-submenu>
				</el-menu>
			</el-aside>
			<el-container>
				<el-main>
					<router-view></router-view>
				</el-main>
			</el-container>
		</el-container>
	
	</div>
	<!-- <el-main style="margin: 0;padding: 0;">
		<router-view></router-view>
	</el-main> -->
	</div>
</template>

<script>
	import {
		getRoleName,
		addPsLog
	} from '../config/request.js'

	export default {
		data() {
			return {
				psUser: {
					id: '',
					usercode: '',
					username: '',
					userpassword: '',
					sex: '',
					age: '',
					entrydate: '',
					dimissiondate: '',
					phonetel: '',
					email: '',
					creationtime: '',
					lastlogintime: '',
					createdby: '',
					lastupdatetime: '',
					userstatus: '',
					roleid: '',
					roleName: ''
				},
				role: [],
				psLogs: {
					usercode: '',
					username: '',
					operateinfo: '退出操作',
					operatedatetime: '',
				}
			}
		},
		methods: {
			formatDateTime(date) {
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
			loads() {
				this.psUser = JSON.parse(sessionStorage.getItem('psUser'));
				getRoleName(this.psUser).then(json => {
					this.role = json;
				})
			},
			exit() {
				const currentDate = new Date();
				const formattedDate = this.formatDateTime(currentDate);
				this.psLogs.operatedatetime = formattedDate;
				this.psLogs.usercode = this.psUser.usercode;
				this.psLogs.username = this.psUser.username;
				addPsLog(this.psLogs).then(json => {})
				location.href = "/logout"
			}
		},
		mounted() {
			this.loads();
		}
	};
</script>

<style scoped>

</style>